﻿using Microsoft.AspNet.SignalR;
using RockBus.Composition.Interfaces;
using System;
using System.Collections.Generic;

namespace RockBus.Services.SignalR
{
    public class SignalRDependencyResolver : DefaultDependencyResolver
    {
        public override object GetService(Type type)
        {
            try
            {
                return base.GetService(type) ?? DependencyManager.Instance.Resolve(type);
            }
            catch
            {
                return null;
            }
        }

        public override IEnumerable<object> GetServices(Type type)
        {
            try
            {
                return base.GetServices(type) ?? DependencyManager.Instance.ResolveAll(type);
            }
            catch
            {
                return new List<object>();
            }
        }
    }
}
